﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace StarLabel.label
{
    public class TSCPrint
    {
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr openport(string PrinterName);
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr closeport();
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr sendcommand(string command);
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr setup(string LabelWidth, string LabelHeight, string Speed, string Density, string Sensor, string Vertical, string Offset);
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr downloadpcx(string Filename, string ImageName);
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr barcode(string X, string Y, string CodeType, string Height, string Readable, string rotation, string Narrow, string Wide, string Code);
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr printerfont(string X, string Y, string FontName, string rotation, string Xmul, string Ymul, string Content);
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr clearbuffer();
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr printlabel(string NumberOfSet, string NumberOfCopy);
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr formfeed();
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr nobackfeed();
        [DllImport("TSCLib.dll", ExactSpelling = true)]
        public static extern IntPtr windowsfont(int X, int Y, int fontheight, int rotation, int fontstyle, int fontunderline, string FaceName, string TextContent);

        public static void DrawBox(int x, int y, int x2, int y2, string thickness)
        {
            string cmd = string.Format("BOX {0},{1},{2},{3},{4}", x, y, x2, y2, thickness);
            sendcommand(cmd);
        }
    
        public static void QRCode(float x, float y, string eccLevel,string cellWidth,string mode,string rotation,string model,string mask,string content)
        {
            string cmd = string.Format("QRCODE {0},{1},{2},{3},{4},{5},{6},{7},\"{8}\"", x, y, eccLevel,cellWidth,mode,rotation,model,mask,content);
            sendcommand(cmd);
        }
    }
}
